<template>
  <div>

    <fieldset class="fieldset_title">
      <legend class="legend_title">基础信息</legend>
      <table class="myTable">
        <tr>
          <td>标准编号</td>
          <td colspan="3">{{detailsData.pollingCode}}</td>
        </tr>
        <tr>
          <td>标准名称</td>
          <td colspan="3">{{detailsData.pollingName}}</td>
        </tr>
        <tr>
          <td>所属部门</td>
          <td>{{detailsData.deptName}}</td>
          <td>适用类别</td>
          <td>{{detailsData.typeName}}</td>
        </tr>

        <tr>
          <td>要求</td>
          <td colspan="3">{{detailsData.addDemand}}</td>
        </tr>

        <tr>
          <td>备注</td>
          <td colspan="3">{{detailsData.remark}}</td>
        </tr>
      </table>
    </fieldset>

    <fieldset class="fieldset_title">
      <legend class="legend_title">适用设备</legend>
      <el-table v-loading="loading" :data="imei.list" :default-sort="{prop: 'id', order: 'descending'}">
        <el-table-column label="序号" align="center" sortable prop="id" />
        <el-table-column label="设备编号" align="center" sortable prop="assetNo">
        </el-table-column>
        <el-table-column label="名称" align="center" sortable prop="emqName" />
        <el-table-column label="品牌" align="center" sortable prop="supplierName" />
        <el-table-column label="类别" align="center" sortable prop="typeName" />
        <el-table-column label="规格型号" align="center" sortable prop="specification" />
      </el-table>
      <!-- 分页组件 -->
      <pagination v-show="imei.total > 0" :total="imei.total" :page.sync="imei.queryParams.pageNo"
        :limit.sync="imei.queryParams.pageSize" @pagination="getImeiList" />

    </fieldset>

    <fieldset class="fieldset_title">
      <legend class="legend_title">点检项目</legend>
      <el-table v-loading="loading" :data="project.list" :default-sort="{prop: 'id', order: 'descending'}">
        <el-table-column label="序号" align="center" sortable prop="id" />
        <el-table-column label="巡检类型" align="center" sortable prop="ptName">
          <template slot-scope="scope">
             <div v-if="scope.row.ptSymbol!=null">
               <img   :src="getImage(scope.row.ptSymbol)" style="width: 20px;height: 20px;padding-top: 2px;" />
               <span>{{scope.row.ptName}}</span>
             </div>
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column label="编号" align="center" sortable prop="ppCode" />
        <el-table-column label="项目" align="center" sortable prop="ppName" />
        <el-table-column label="方法及基准" align="center" sortable prop="ppMethod" />
        <el-table-column label="类型" align="center" sortable prop="ppType" />
        <el-table-column label="上限" align="center" sortable prop="ppUpperLimit" />
        <el-table-column label="下限" align="center" sortable prop="ppLowerLimit" />
        <el-table-column label="可选项" align="center" sortable prop="ppOptions" />
        <el-table-column label="正常选项	" align="center" sortable prop="ppNormal" :formatter="getTextInt" />
        <el-table-column label="必填	" align="center" sortable prop="ppNormal" :formatter="getTextInt" />
        <el-table-column label="必须拍照	" align="center" sortable prop="ppPicturesState" :formatter="getTextBool" />
        <el-table-column label="参考附件" align="center" sortable prop="ppPictures" >
          <template slot-scope="scope">
             <div v-if="scope.row.ppPictures!=null">
               <img  v-for="(item,index) in scope.row.ppPictures.split(';')" :src="item" style="width: 25px;height: 25px;" />
             </div>
            <span v-else>--</span>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页组件 -->
      <pagination v-show="project.total > 0" :total="project.total" :page.sync="project.queryParams.pageNo"
        :limit.sync="project.queryParams.pageSize" @pagination="getProjecttList" />
    </fieldset>

  </div>
</template>

<script>
  import {
    getStandardMy,
    getImeiInfoBz
  } from "@/api/polling/standard";

  import {
    getPollingProjectBzList
  } from "@/api/polling/pollingProject";

  export default {
    name: "StandardInfo",
    components: {},
    data() {
      return {
        loading: false,
        list: [],
        id: null,
        detailsData: {},
        imei: {
          queryParams: {
            pageNo: 0,
            pageSize: 10,
            id: null
          },
          list: [],
          total: 0
        },
        project: {
          queryParams: {
            pageNo: 0,
            pageSize: 10,
            id: null
          },
          list: [],
          total: 0
        }
      }
    },
    mounted() {
      this.id = this.$route.query.uid;
      this.loadInfo();
    },
    methods: {
      getTextInt(a,b){
        let aValue=a[b.property];
        if(aValue == null){
          return "--"
        }
        return aValue==1?"是":"否";
      },
      getTextBool(a,b){
        let aValue=a[b.property];
        if(aValue == null){
          return "--"
        }
        return aValue?"是":"否";
      },
      getImage(img) {
        return require('@/assets/icons/' + img);
      },
      loadInfo() {
        getStandardMy({id: this.id}).then(res => {
          var list = res.data.list;
          if (list != undefined && list.length > 0) {
            this.detailsData = list[0];
          }
        });

        this.project.queryParams.id = this.id
        this.getImeiList();
        this.getProjecttList();

      },
      getImeiList() {
        getImeiInfoBz(this.id).then(res => {
          console.log("getImeiList",res)
          this.imei.list = res.data.list;
          this.imei.total = res.data.total;
        });
      },
      getProjecttList() {
        getPollingProjectBzList(this.project.queryParams).then(res => {
           console.log("geProjecttList",res)
          this.project.list = res.data.list;
          this.project.total = res.data.total;

        })

      }
    }
  }
</script>

<style>
  .legend_title {
    font-size: 16px;
    color: #05A380;
    padding: 10px 0px;
    font-weight: 700;
  }

  .fieldset_title {
    margin-top: 20px;
  }


  .myTable td {
    border: 1px solid #DCDFE6;
    width: 11em;
    text-align: center;
    line-height: 28px;
  }

  .myTable {
    box-sizing: border-box;
    border-spacing: 0;
    border-collapse: collapse;
    border-spacing: 2px;
    border-color: grey;
    table-layout: fixed;
    border-collapse: collapse !important;
    width: 100%;
    max-width: 900px;
    max-width: 500px;
    margin-top: 10px;
    font-size: 12px;
  }
</style>
